pp108 : Creating XForms Dynamically

Creating XForms Dynamically

This topic describes how to dynamically create XForms.

In addition to using the XForms Designer, you can use Java API to create XForms. Using Process Platform XForms, it is possible to view and dynamically generate the user interface of XForms from Java classes. You can use the API exposed by Process Platform XForms to generate a .caf file for Java class.

For information about the Java API used for dynamically generated XForms, refer to the com.eibus.xforms package and the XFormsDef class name at Java API.

  1. Select a starting point and click (User Interface) to create the XForm. The Untitled User Interface - User Interface App Palette appears and the XForms Designer displays.
  2. Click Click here to create Dynamic XForm in the XForms Designer.
  3. Type the fully qualified class path of the implementation class in the Qualified Class Name field. An example of the fully qualified class path is com.cordys.test.dynamic.DynamicXformGenerationone. This specifies the Java class using which you can create an XForm.

    Note:
    The XForms service container loads the specified Java class dynamically, if the Java archive is present in the <Process_Platform_Installation_Directory>/components/xfruntime/dynamicxforms folder. In this case, you do not need to restart the XForms service container. However, if the Java archive is not present in the mentioned folder, specify the location of the Java archive in the JRE Configuration of the XForms service container and restart the service container in order to load the Java class.

    Remember
    To be able to use an implementation class to create a dynamic XForm, the IXFormsDefinition interface definition must be implemented for the class. This makes the implementation class eligible for generating dynamic XForms. You can use the getXFormsDefinition and getWSDLDefinition Web service operations to develop a dynamic XForm. The getXFormsDefinition Web service operation enables the acceptance of parameters from the URL. You can pass the parameters supported by the getXFormsDefinition and getWSDLDefinition Web service operations through the URL.

  4. Click OK.

    Note: When you click Cancel, the Untitled User Interface - User Interface App Palette displays without saving the qualified class name you entered.

    The XForm is automatically generated from the specified Java Class, and displays in the XForms Designer in the read-only mode. It is not possible to modify the XForm from the XForms Designer.

    Note: You can also view the properties of the dynamic XForm. The property sheet displays in the read-only mode and is not available for modifications. Additionally, after creating a dynamic XForm, it is possible to use the URL to pass parameters to the XForm (.caf file). These parameters, if any, are stored in a Hashtable with the parameter names as key. After the XForm is created, you can publish it to the organization and use it in a business process. You can also translate a dynamic XForm. Dynamic XForms are not cached.

    Note:
    It is possible to view the WSDL of a current dynamic XForm, if the getWSDLDefinition Web service operation is implemented. To view its WSDL, type the URL of the XForm followed by ?WSDL as a suffix.

Example

The following example code demonstrates the implementation of a Java Class using IXFormsDefinition and the use of the getXFormsDefinition and getWSDLDefinition Web service operations.

Pre-requisite: Following jars should be in CLASSPATH before compile the given sample java code.

<Process_Platform_install_dir>/cordyscp.jar
<Process_Platform_install_dir>/components/xfruntime/xfruntime.jar
<Process_Platform_install_dir>/components/xfruntime/dynamicxforms

package com.cordys.test.dynamic; import java.util.HashMap; import com.eibus.xforms.XFormsDef; import com.eibus.xforms.persistence.IXFormsDefinition; import com.eibus.xml.nom.Document; public class DynamicXformGenerationone implements IXFormsDefinition { public void genXForm(XFormsDef xf) { int root = xf.getMainForm(); xf.setXFormsVersion("2"); xf.addInput(root, "Employee", "empID", " "); xf.linkStyleSheet("/cordys/wcp/style/MyCss.css"); } public int getXFormsDefinition( HashMap parameters ) { Document document = NOMDocumentPool.getInstance().lendDocument(); //This node must be either a valid XForms definition or zero. Framework will take care of this when it is zero. int xformsDefinition = 0; XFormsDef xf = null; try { xf = new XFormsDef(xformsDefinition); genXForm(xf); } finally { NOMDocumentPool.getInstance().returnDocument(document); } return xf.getXFormsDefinition(); } public int getWSDLDefinition( HashMap parameters ) { return 0; } }

Related concepts

XForms Designer
XForms - A W3C standard

Related reference

XForms Toolbar
XForms Toolbox
Generating Input and Output User Interfaces
Interface Design Overview
Predefined XForms

Related information

XForms API